package org.eking.bigdata.hadoop;

import java.io.IOException;

import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.JobClient;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.Partitioner;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;


public class TestMpr extends Configured{

	public static void main(String[] args) {
		// 
		   

		try {	
			/*
			JobConf conf = new JobConf(TestMap.class);		
			conf.setJobName("Max temperature");  
			conf.setMapperClass(TestMap.class);
			conf.setReducerClass(TestReduce.class);
			conf.setOutputKeyClass(Text.class);
			conf.setOutputValueClass(IntWritable.class);
			conf.setPartitionerClass((Class<? extends Partitioner>) TestPartition.class);
			*/
			
			Job job = new Job();
			job.setJarByClass(TestMpr.class);
			job.setJobName("Test MapReduce");
			FileInputFormat.addInputPath(job, new Path("/lele/mapr.txt"));
			FileOutputFormat.setOutputPath(job, new Path("/lele/result"));
			job.setMapperClass(TestMap.class);
			//job.setPartitionerClass(TestPartition.class);
			job.setReducerClass(TestReduce.class);
			
			
			job.setOutputKeyClass(Text.class);
			job.setOutputValueClass(IntWritable.class);
			
			
			job.waitForCompletion(true);
			System.out.println("success2!!");
			
		} catch (IllegalArgumentException e) {
			// 
			e.printStackTrace();
		} catch (IOException e) {
			// 
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// 
			e.printStackTrace();
		} catch (InterruptedException e) {
			// 
			e.printStackTrace();
		}


	}

}
